//
//  SXTMyMessageTableViewCell.m
//  8.18项目
//
//  Created by ma c on 16/8/18.
//  Copyright © 2016年 zhang. All rights reserved.
//

#import "SXTMyMessageTableViewCell.h"

@interface SXTMyMessageTableViewCell ()
//图标
@property (strong, nonatomic)   UIImageView  *iconImage;
//label字
@property (nonatomic,strong) UILabel * titleLabel;
//下一步符号
@property (nonatomic,strong) UIImageView * nextImage;
//分割线
@property (nonatomic,strong) UILabel * linLabel;


@end

@implementation SXTMyMessageTableViewCell

-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {

    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    
    if (self) {
        [self addSubview:self.iconImage];
        [self addSubview:self.titleLabel];
        [self addSubview:self.nextImage];
        [self addSubview:self.linLabel];
    }
    return self;
}

//布局
- (void)layoutSubviews {

    [super layoutSubviews];
    
    __weak typeof (self) weakSelf = self;
    [_iconImage mas_makeConstraints:^(MASConstraintMaker *make) {
        make.size.mas_offset(CGSizeMake(20, 20));
        make.left.equalTo(weakSelf.mas_left).offset(15);
        make.centerY.equalTo(weakSelf.mas_centerY);
    }];
    
    [_titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.size.mas_equalTo(CGSizeMake(140, 15));
        make.centerY.equalTo(weakSelf.mas_centerY);
        make.left.equalTo(weakSelf.iconImage.mas_right).offset(15);
    }];
    
    [_nextImage mas_makeConstraints:^(MASConstraintMaker *make) {
        make.size.mas_equalTo(CGSizeMake(10, 14));
        make.centerY.equalTo(weakSelf.mas_centerY);
        make.right.equalTo(weakSelf.mas_right).offset(-15);
    }];
    
    [_linLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.height.mas_equalTo(1);
        make.left.equalTo(weakSelf.titleLabel.mas_left);
        make.right.equalTo(weakSelf.mas_right);
        make.bottom.equalTo(weakSelf.mas_bottom);
    }];
    

}

-(void)setSourceDic:(NSDictionary *)sourceDic {

    _titleLabel.text = sourceDic[@"title"];
    _iconImage.image = [UIImage imageNamed:sourceDic[@"image"]];

}


#pragma mark - 初始化

-(UIImageView *)iconImage {

    if (!_iconImage) {
        _iconImage = [[UIImageView alloc]init];
    }
    return _iconImage;
}

-(UILabel *)titleLabel{

    if (!_titleLabel) {
        _titleLabel = [[UILabel alloc]init];
        _titleLabel.font = [UIFont systemFontOfSize:15.0];
        _titleLabel.textColor = [UIColor blackColor];
    }
    return _titleLabel;
}

-(UIImageView *)nextImage {

    if (!_nextImage) {
        _nextImage = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"下一步"]];
    }
    return _nextImage;
}

-(UILabel *)linLabel {

    if (!_linLabel) {
        _linLabel = [[UILabel alloc]init];
        _linLabel.backgroundColor = MainColor;
    }
    return _linLabel;
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];
    
    // Configure the view for the selected state
}

















@end
